#include "../Tools/GLHeaders.hpp"
#include "Obj0.hpp"
#include <cmath>

void Obj0::Draw(void){
	glPushAttrib(GL_COLOR_BUFFER_BIT|GL_CURRENT_BIT|GL_TEXTURE_BIT);	
	glDisable(GL_TEXTURE_2D); 
	if(activate)
		glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
	else
		glColor4f(0.0f, 1.0f, 0.0f, 1.0f);

  glCallList(list_id);
	glPopAttrib();
}

void Obj0::Activate(void){
	activate = true;
}

void Obj0::Desactivate(void){
	activate = false;
}

Obj0::Obj0(void){
	activate = false;	
  list_id = glGenLists(1); // create one DisplayList
  glNewList(list_id, GL_COMPILE);
 	GLUquadricObj *quadratic = gluNewQuadric();
  gluQuadricNormals(quadratic, GLU_SMOOTH);

 	glLineWidth(2);
  glBegin(GL_LINES);
  glVertex3f(0.0f, 0.0f, 0.0f);
  glVertex3f(4.0f, 0.0f, 0.0f);
	glVertex3f(0.0f, 0.0f, 0.0f);
	glVertex3f(0.0f, 1.0f, 0.0f);
  glEnd();

	glTranslatef( 4.0f, 0.0f, 0.0f);
  gluSphere(quadratic, 0.1f, 8, 8);
  glTranslatef(-4.0f, 1.0f, 0.0f);
  gluSphere(quadratic, 0.1f, 8, 8);
	glTranslatef( 0.0f,-1.0f, 0.0f);
 	glEndList();
}

Obj0::~Obj0(void){
  glDeleteLists(list_id,1);
}
